package org.stvd.entities.quartz;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.format.annotation.DateTimeFormat;
import org.stvd.entities.base.BaseEntity;
import org.stvd.entities.common.LongJsonDeserializer;
import org.stvd.entities.common.LongJsonSerializer;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

/**
 * @title QuartzJob
 * @description 定时任务
 * @auther houzx
 * @date 2022年03月09日
 */
@Entity
@Table(name="qrtz_job")
public class QuartzJob extends BaseEntity{
    
    private static final long serialVersionUID = -34367670792194174L;

    @Id
    @Column(name="id", nullable = false)
    @JsonDeserialize(using = LongJsonDeserializer.class)
    @JsonSerialize(using = LongJsonSerializer.class)
    private Long id = null;

    /**
     * 任务名称
     */
    @Column(name="job_name", nullable = false)
    @NotEmpty(message="任务名称不能为空")
    @Length(max = 200, message = "任务名称长度超出最大限制")
    private String jobName = "";

    /**
     * cron表达式
     */
    @Column(name="cron_expression", nullable = false)
    @NotEmpty(message="cron表达式不能为空")
    private String cronExpression = "";

    /**
     * 任务执行类（包名+类名）
     */
    @Column(name="bean_class", nullable = false)
    @NotEmpty(message="任务执行类不能为空")
    private String beanClass = "";

    /**
     * 任务状态（0-停止，1-运行）
     */
    @Column(name="status", nullable = false)
    private String status = "";

    /**
     * 任务分组
     */
    @Column(name="job_group", nullable = false)
    private String jobGroup = "";

    /**
     * 参数
     */
    @Column(name="job_data_map")
    private String jobDataMap;

    /**
     * 下一次执行时间
     */
    @Column(name="next_exec_date")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date nextExecDate = null;

    /**
     * 创建人
     */
    @Column(name="create_user", nullable = false)
    private String createUser = "";

    /**
     * 创建时间
     */
    @Column(name="create_time", nullable = false)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime = null;

    /**
     * 更新时间
     */
    @Column(name="modify_time")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date modifyTime = null;

    /**
     * 任务描述
     */
    @Column(name="remarks")
    @Length(max = 200, message = "任务描述长度超出最大限制")
    private String remarks = "";

    /**
     * 排序编号
     */
    @Column(name="orderno", nullable=false)
    @NotNull(message="排序编号不能为空")
    @Min(message="排序编号请输入1~9999之间的整数", value = 1)
    @Max(message="排序编号请输入1~9999之间的整数", value = 9999)
    private Integer orderNo = null;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getJobName() {
        return jobName;
    }

    public void setJobName(String jobName) {
        this.jobName = jobName;
    }

    public String getCronExpression() {
        return cronExpression;
    }

    public void setCronExpression(String cronExpression) {
        this.cronExpression = cronExpression;
    }

    public String getBeanClass() {
        return beanClass;
    }

    public void setBeanClass(String beanClass) {
        this.beanClass = beanClass;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getJobGroup() {
        return jobGroup;
    }

    public void setJobGroup(String jobGroup) {
        this.jobGroup = jobGroup;
    }

    public String getJobDataMap() {
        return jobDataMap;
    }

    public void setJobDataMap(String jobDataMap) {
        this.jobDataMap = jobDataMap;
    }

    public Date getNextExecDate() {
        return nextExecDate;
    }

    public void setNextExecDate(Date nextExecDate) {
        this.nextExecDate = nextExecDate;
    }

    public String getCreateUser() {
        return createUser;
    }

    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getModifyTime() {
        return modifyTime;
    }

    public void setModifyTime(Date modifyTime) {
        this.modifyTime = modifyTime;
    }

    public String getRemarks() {
        return remarks;
    }

    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }

    public Integer getOrderNo() {
        return orderNo;
    }

    public void setOrderNo(Integer orderNo) {
        this.orderNo = orderNo;
    }

    public static long getSerialversionuid() {
        return serialVersionUID;
    }
    
}
